package com.muyu.system.domain.resp;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.system.domain.model.SysLogininforListModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 登录信息返回对象
 * @author yangchaoshun
 * @version 1.0
 * @description: 登录信息返回对象
 * @date 2025/2/23 18:18
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SysLogininforListResp {
    /**
     * ID
     */
    private Long infoId;

    /**
     * 用户账号
     */
    private String userName;

    /**
     * 状态 0成功 1失败
     */
    private String status;

    /**
     * 地址
     */
    private String ipaddr;

    /**
     * 描述
     */
    private String msg;

    /**
     * 访问时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date accessTime;

    public static SysLogininforListResp buildSysLogininforResp(SysLogininforListModel sysLogininforListModel) {
        return SysLogininforListResp.builder()
                .infoId(sysLogininforListModel.getInfoId())
                .userName(sysLogininforListModel.getUserName())
                .status(sysLogininforListModel.getStatus())
                .ipaddr(sysLogininforListModel.getIpaddr())
                .msg(sysLogininforListModel.getMsg())
                .accessTime(sysLogininforListModel.getAccessTime())
                .build();
    }
}
